﻿/*
namespace estoque
{
    using System.Collections.Generic;
    using System.IO;
    using Microsoft.TeamFoundation.WorkItemTracking.Client;

    public class Exporter
    {
        public static void WriteExcelFile(List<OmniTrackerRequest> list, string path)
        {
            using (ExcelSheet worksheet = new ExcelSheet(path))
            {
                // Schreiben der Tabellen-Header
                worksheet.Cells[1, 1] = "Number";
                worksheet.Cells[1, 2] = "Title";
                worksheet.Cells[1, 3] = "Priority ";
                worksheet.Cells[1, 4] = "State";
                worksheet.Cells[1, 5] = "Bearbeiter bei CAS";
                worksheet.Cells[1, 6] = "Description";
                worksheet.Cells[1, 7] = "Answers";
                worksheet.Cells[1, 8] = "Build";
                worksheet.Cells[1, 9] = "Builddatum";
                worksheet.Cells[1, 10] = "Version";
                worksheet.Cells[1, 11] = "Testbuild";
                worksheet.Cells[1, 12] = "Testdatum";
                worksheet.Cells[1, 13] = "Creation_Date";
                worksheet.Cells[1, 14] = "Last Change";
                worksheet.Cells[1, 15] = "Applicant";
                worksheet.Cells[1, 16] = "Responsible";
                worksheet.Cells[1, 17] = "Programm";
                worksheet.Cells[1, 18] = "Class";
                worksheet.Cells[1, 19] = "Verbundener OT";
                worksheet.Cells[1, 20] = "Attachment";

                // Schreiben der Tabellen Inhalte
                for (int i = 0; i < list.Count; i++)
                {
                    int sheetPosY = i + 2;

                    worksheet.Cells[sheetPosY, 1] = list[i].Number;
                    worksheet.Cells[sheetPosY, 2] = list[i].Title;
                    worksheet.Cells[sheetPosY, 3] = list[i].Prio;
                    worksheet.Cells[sheetPosY, 4] = list[i].State;
                    worksheet.Cells[sheetPosY, 5] = "";
                    worksheet.Cells[sheetPosY, 6] = list[i].Description;
                    worksheet.Cells[sheetPosY, 7] = "";
                    worksheet.Cells[sheetPosY, 8] = list[i].AdditionalInfos["Build"]; ;
                    worksheet.Cells[sheetPosY, 9] = list[i].AdditionalInfos["Builddatum"];
                    worksheet.Cells[sheetPosY, 10] = list[i].AdditionalInfos["Programmversion"];
                    worksheet.Cells[sheetPosY, 11] = "";
                    worksheet.Cells[sheetPosY, 12] = "";
                    worksheet.Cells[sheetPosY, 13] = list[i].CreationDate;
                    worksheet.Cells[sheetPosY, 14] = list[i].LastChanged;
                    worksheet.Cells[sheetPosY, 15] = list[i].Applicant;
                    worksheet.Cells[sheetPosY, 16] = list[i].Responsible;
                    worksheet.Cells[sheetPosY, 17] = list[i].Application;
                    worksheet.Cells[sheetPosY, 18] = list[i].Class;
                    worksheet.Cells[sheetPosY, 19] = "";
                    worksheet.Cells[sheetPosY, 20] = string.Join<string>(";", list[i].Attachments.Keys);
                }

                // Tabelle noch etwas "schöner" machen.
                worksheet.AutoFitColumns(20);
                worksheet.AutoFitRows(list.Count);
            }
        }

        public static void WriteAttachments(List<OmniTrackerRequest> requestList, string resultPath)
        {
            foreach (OmniTrackerRequest request in requestList)
            {
                string path = Path.Combine(resultPath, request.Number);
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                // write the files on disk
                foreach (string attachmentName in request.Attachments.Keys)
                {
                    byte[] content = request.Attachments[attachmentName];
                    FileStream fs = new FileStream(Path.Combine(path, attachmentName), FileMode.Create, FileAccess.ReadWrite);
                    BinaryWriter bw = new BinaryWriter(fs);
                    bw.Write(content);
                    bw.Close();
                }

                // answers file schreiben
                if (!string.IsNullOrEmpty(request.Answers))
                {
                    File.WriteAllText(Path.Combine(path, "answers.txt"), request.Answers);
                }

                // OTR-File dazuschreiben
                request.WriteOtrFile(path);
            }
        }

        public static void WriteExcelFile(WorkItemCollection list, string path)
        {
            using (ExcelSheet worksheet = new ExcelSheet(path))
            {
                // Schreiben der Tabellen-Header
                worksheet.Cells[1, 1] = "Id";
                worksheet.Cells[1, 2] = "Title";
                worksheet.Cells[1, 3] = "Project";
                worksheet.Cells[1, 4] = "State";
                worksheet.Cells[1, 5] = "IterationPath";
                worksheet.Cells[1, 6] = "AreaPath";
                worksheet.Cells[1, 7] = "Description";
                worksheet.Cells[1, 8] = "Assigned To";
                worksheet.Cells[1, 9] = "Type";

                // Schreiben der Tabellen Inhalte
                for (int i = 0; i < list.Count; i++)
                {
                    int sheetPosY = i + 2;

                    worksheet.Cells[sheetPosY, 1] = list[i].Id;
                    worksheet.Cells[sheetPosY, 2] = list[i].Title;
                    worksheet.Cells[sheetPosY, 3] = list[i].Project.Name;
                    worksheet.Cells[sheetPosY, 4] = list[i].State;
                    worksheet.Cells[sheetPosY, 5] = list[i].IterationPath;
                    worksheet.Cells[sheetPosY, 6] = list[i].AreaPath;
                    worksheet.Cells[sheetPosY, 7] = list[i].Description;
                    worksheet.Cells[sheetPosY, 8] = list[i].Fields["Assigned To"].Value;
                    worksheet.Cells[sheetPosY, 9] = list[i].Type.Name;
                }

                worksheet.AutoFitColumns(10);
                worksheet.AutoFitRows(list.Count);
            }
        }
    }
}
*/